using System;
using App_Code.Modules;
using Portal.Data.Entity;

public partial class Modules_WebpartPage_ClonePart : WebpartPageModule
{
    protected override string Action
    {
        get { return "clonepart"; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        var id = Request["id"];
        object obj = FindByPrimaryKey(typeof(Webpart), "partid");
        if (obj == null || id == null)
        {
            Forward("error");
            return;
        }
        var wp = (Webpart)obj;
        var part = new Webpart
        {
            Zone = wp.Zone,
            Definition_ID = wp.Definition_ID,
            Page_ID = wp.Page_ID,
            WebPartOrder = wp.WebPartOrder + 1,
            Properties = wp.Properties
        };
        part.Save();        
        ActionPage.newParams.Add("id", id);
        Forward("finish");
    }
}